# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=gvm-libs
pkgver=11.0.1
pkgrel=0
pkgdesc="Greenbone Vulnerability Management Libraries"
url="https://www.openvas.org/"
arch="all"
license="GPL-2.0-or-later"
options="!check" # test fails: https://github.com/greenbone/gvm-libs/issues/279
pkgusers="gvm"
pkggroups="gvm"
install="$pkgname.pre-install"
makedepends="cmake bison glib-dev libpcap-dev libssh-dev
	hiredis-dev gnutls-dev util-linux-dev
	libgcrypt-dev libksba-dev openldap-dev
	gpgme-dev gpgmepp net-snmp-libs e2fsprogs-dev
	clang-dev freeradius-client-dev
	doxygen libxslt graphviz xmltoman perl-sql-translator
	libxml2-dev"
subpackages="$pkgname-dev $pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/greenbone/gvm-libs/archive/v$pkgver.tar.gz
	malloc-trim.patch
	glib-include-path.patch
	strptime.patch"

prepare() {
	default_prepare
	mkdir build
}

build() {
	cd $builddir/build
	cmake -DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DBUILD_STATIC=0 \
		-DBUILD_SHARED=1 \
		-DLIBDIR=/usr/lib \
		-DSYSCONFDIR=/etc \
		-DLOCALSTATEDIR=/var \
		-DGVM_PID_DIR=/var/lib/gvm \
	..
	make
}

check() {
	cd $builddir/build
	return 0
}

package() {
	cd $builddir/build
	make DESTDIR="$pkgdir" install
	mkdir -p "$pkgdir"/var/lib/gvm
	chown -R $pkgusers:$pkggroups "$pkgdir"/var/lib/gvm
}

doc() {
	cd $builddir/build
	default_doc
	make doc
	mkdir -p "$subpkgdir"/usr/share/doc/$pkgname
	mv doc/generated/* "$subpkgdir"/usr/share/doc/$pkgname
}

sha512sums="159acbe8e24f172398a6396988b87676a214fa15c2985e67845dcad1ebcb92ba5e2a19cee2994dc7cd0cac706992e81e8c6a793e99216aaac87a91c1c72c9a46  gvm-libs-11.0.1.tar.gz
ae93ac7ec929325926d785bb58ed9c09f8bdaf518adf09db54bb9a8a4b5e4474c0ab61fc987c91114f2013cbe39868115006b528865fbd027e5b88eca58f1954  malloc-trim.patch
c0fe0add24cb4336f0ce313197042e60a3aba3eeb983f31b243e665a488e520ffa260ab9a3feb852500310a9df66f2eaf82ac4294d7980b983a78454b30eb9f9  glib-include-path.patch
b10f2b6a8e126a184c65c91bdd18a21e4ee16cbc442775288a11c2768c8e5c1db4ce3749025e7cc3f360c7c1011b79dca836fee742fb9f06034ca0a986f718b5  strptime.patch"
